<?php
namespace app\daohang\event;

use think\Controller;

class Task extends Controller
{
    //更新标签统计
    public function tagsCount()
    {
        //分组查询统计
        $item = db('term_map')
        ->field('term_id,count(term_id) as term_count')
        ->where('term_id > 0')
        ->group('term_id')
        ->order('term_count desc')
        ->select();
        
        //空数据集
        if($item->isEmpty()){
            $this->error(lang('fail'));
        }
        
        //批量更新
        dbUpdateAll('term', $item->toArray());
        
        //返回结果
        $this->success(lang('success'),'index/index');
    }
}